package 进阶.线程.线程状态;


//等待唤醒
public class demo01 {
    public static void main(String[] args) {
        //创建锁对象，保证唯一
        Object obj = new Object();

        //创建顾客线程
        new Thread(){
            @Override
            public void run() {
                System.out.println("0000000000000000000000");
                synchronized (obj){
                    try {
                        obj.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("111111111111111111111111111111111");
                }
            }
        }.start();

        //创建老板线程
        new Thread(){
            @Override
            public void run() {

                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (obj){
                    obj.notify();
                    System.out.println("2222222222222222222222222222222");
                }
            }
        }.start();
    }
}
